﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RPAAction.Access_CSO
{
    internal class Access_RunVBAFunction : AccessAction
    {
        public string Ret => ret;

        public Access_RunVBAFunction(
            string accessPath,
            string foucName,
            string param1,
            string param2,
            string param3,
            string param4,
            string param5,
            string param6,
            string param7,
            string param8,
            string param9,
            string param10
        )
            : base(accessPath)
        {
            this.foucName = foucName;
            Params = new string[] { param1, param2, param3, param4, param5, param6, param7, param8, param9, param10 };
            Run();
        }

        public Base.RPAAction Out(out string Ret)
        {
            Ret = ret;
            return this;
        }

        protected override void Action()
        {
            base.Action();
            ret = app.Run(
                foucName,
                Params[0] == "" ? Type.Missing : Params[0],
                Params[1] == "" ? Type.Missing : Params[1],
                Params[2] == "" ? Type.Missing : Params[2],
                Params[3] == "" ? Type.Missing : Params[3],
                Params[4] == "" ? Type.Missing : Params[4],
                Params[5] == "" ? Type.Missing : Params[5],
                Params[6] == "" ? Type.Missing : Params[6],
                Params[7] == "" ? Type.Missing : Params[7],
                Params[8] == "" ? Type.Missing : Params[8],
                Params[9] == "" ? Type.Missing : Params[9]
            ).ToString();
        }

        private readonly string foucName;
        private readonly string[] Params;
        private string ret = "";
    }
}
